#!/usr/bin/python

from decimal import *
import os


#simulation en lancant le programme c++
tab = range(1,100,1)
os.system("rm -rf ../output/simulation.out")
os.system("touch  ../output/simulation.out")


for x in tab:
    to  =(Decimal(x)/Decimal(1000))
    cmd = "../main "+str(to)+" "+str(10000) +" >> simulation.out"
    os.system(cmd)
    print cmd;



#postraitement et trace de courbe
print "influence du taux d'ecriture sur le resident Set"
print "fichier de donnees en sortie: data.out"
print "script gnuplot pour tracer la courbe: plot.gp"

f_in = open('../output/simulation.out','r')
f_out= open('../data/data.dat','w+')

f_out.write("p VmSiz VmPeak VmLib VmExe VmData VmRSS VmHWM\n")

#les lignes de sortie
lines= f_in.readlines()

#postraitement
for line in lines:
    if(line[0]=='#'):
        #print line;
        f_out.write(line.replace('#',''));

f_in.close()
f_out.close()
os.system("./postraitement.py")
os.system("gnuplot ../gnuplot/plot.gp")
print("nom de la courbe: rss.ps")
